package com.qf.simpleTrigger;

import com.qf.util.SpringBean;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * IntelliJ IDEA -> springboot120622
 * 2019/12/7 1:34
 *
 * @author zmyao
 * 别看，我是渣渣。
 */
//生产调度器对象
    @Configuration
public class Factory {

        @Autowired
        private SpringBean springBean;

    @Bean
    public SchedulerFactoryBean factoryBean(){
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setJobFactory(springBean);
        return  schedulerFactoryBean;
    }
    @Bean
    public Scheduler getsch(@Qualifier("factoryBean") SchedulerFactoryBean factoryBean){
        return  factoryBean.getObject();
    }

}
